﻿using Net5ApiANdWpfClient.Lib.Model.SystemAdmin;
using Net5ApiANdWpfClient.Lib.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfClient.OutsourceManger
{
    /// <summary>
    /// AddOutSource.xaml 的交互逻辑
    /// </summary>
    public partial class AddOutSource : Window
    {
        outsource outs = new outsource();
        public AddOutSource()
        {
            InitializeComponent();
            this.DataContext = outs;
        }
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(outs.os_name))
            {
                MessageBox.Show("请输入外协公司名称!");
                return;
            }
            if (string.IsNullOrEmpty(outs.os_email))
            {
                MessageBox.Show("请输入邮箱!");
                return;
            }
            if (string.IsNullOrEmpty(outs.os_phone))
            {
                MessageBox.Show("请输入电话!");
                return;
            }
            if (string.IsNullOrEmpty(outs.os_tel))
            {
                MessageBox.Show("请输入电话!");
                return;
            }
            if (string.IsNullOrEmpty(outs.os_address))
            {
                MessageBox.Show("请输入外协地址!");
                return;
            }
            outs.os_createtime = DateTime.Now;
            OutsourceService outss = new OutsourceService();
            string mess = "";
            bool result = outss.AddOutsource(outs, out mess);
            if (result)
            {
                MessageBox.Show($"添加成功!{mess}");
               
            }
            else
            {
                MessageBox.Show($"添加失败!{mess}");
            }
        }
        private void Close_Click(object sender, RoutedEventArgs e)
        { 
            
        }
    }
}
